package name.fowler.refactoring.simplestore.calculators;

import name.fowler.refactoring.simplestore.domain.Customer;
import name.fowler.refactoring.simplestore.domain.Rental;
import name.fowler.refactoring.simplestore.domain.movie.MovieNewRelease;

public class CustomerFrequentStrategy implements FrequentStrategy {

	@Override
	public int calculateDiscount(Customer customer) {
		int frequentRenterPoints = 0;
		for (Rental rental : customer.getRentals()) {
			frequentRenterPoints++;
	
			if ((rental.getMovie() instanceof MovieNewRelease)
					&& (rental.getDaysRented() > 1)) {
				frequentRenterPoints++;
			}
		}
		return frequentRenterPoints;
	}
}
